package org.example.common.redis.utils;

/**
 * 缓存处理
 */
public class CacheHelper {
    private CacheHelper(){}
    private  static CacheHelper cacheHelper =null;

    public static CacheHelper getStorage(){
        if(cacheHelper ==null){
            synchronized (CacheHelper.class){
                if (cacheHelper ==null){
                    cacheHelper =new CacheHelper();
                }
            }
        }
        return cacheHelper;
    }

    /**
     * 添加缓存
     * @param key
     * @param value
     */
    public void putInCache(String key, Object value) {
        RedisUtils.setCacheObject(key, value);
    }

    /**
     * 获取缓存
     * @param key
     * @return
     */
    public Object getFromCache(String key) {
        return RedisUtils.getCacheObject(key);
    }

    /**
     * 缓存移除
     * @param key
     */
    public void evictCache(String key) {
        RedisUtils.deleteObject(key);
    }
}
